<template>
  <div style="width: 500px">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="表名">
        <el-select v-model="form.table" placeholder="请选择表">
          <el-option v-for="val in tableData" :key="val.id" :label="val.tableName" :value="val.tableName"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="作者">
        <el-input v-model="form.author"></el-input>
      </el-form-item>
      <el-form-item label="输出目录" >
        <el-input v-model="form.outputDir" placeholder="例：D://demo/...."></el-input>
      </el-form-item>
      <el-form-item label="包名" >
        <el-input v-model="form.parentPackage" placeholder="例：com.example.author"></el-input>
      </el-form-item>
      <el-form-item label="模块名称" >
        <el-input v-model="form.moduleName" placeholder="例：test"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData:[],
      form: {
        table: "",
        author:"",
        outputDir:"",
        parentPackage:"",
        moduleName:"",
        
      },
    };
  },
  created(){
      this.$axios
        .get("http://localhost:8888/sys/tableNames")
        .then((res) => {
          if (res.data.code==0) {
            this.tableData = res.data.data;
            console.log(this.tableData);
          } else {
            this.$message.error(res.data.msg);
          }
        });
  },
  methods: {
    onSubmit() {
      this.$axios
        .post("http://localhost:8888/sys/generator",this.form)
    },
  },
};
</script>

